﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using YJKSparseDisOfRoom.ModelLayer;

namespace YJKSparseDisOfRoom
{
	[Transaction(TransactionMode.Manual)]
	internal class CmdRoomCurveBean : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			foreach (Element element in new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document).OfClass(typeof(SpatialElement)))
			{
				if (element is Room)
				{
					List<BaseCurveBean> list = new List<BaseCurveBean>();
					foreach (IEnumerable<BoundarySegment> enumerable in (element as Room).GetBoundarySegments(new SpatialElementBoundaryOptions()))
					{
						list = new List<BaseCurveBean>();
						foreach (BoundarySegment boundarySegment in enumerable)
						{
							list.Add(new BaseCurveBean(boundarySegment.GetCurve(), true, false));
						}
						new CurveBeanUnit(list, true);
					}
				}
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
